C
C *** LAST REVISED ON 12-AUG-1987 12:04:33.79
C *** SOURCE FILE: [DL.GRAPHICS.LONGLIB]LONGLIB3D.FOR
C
C **************************************************************************
C
C	LONGLIB3D LIBRARY ROUTINES FOR 3-D PLOTTING WITHOUT HIDDEN
C	LINE REMOVAL.
C
C	THIS FILE IS FORTRAN 77 COMPATIBLE WITH THE FOLLOWING EXCEPTIONS
C		1. TRAILING COMMENTS WITH ! SEPARATOR ARE USED.
C		2. TABS FOR INDENTING LINES ARE USED.
C		3. INTEGER*2 IS USED FOR THE SYM3D ROUTINE (ALSO
C		   SEE COMMENTS ABOUT SYMBOL WHICH WILL APPLY).
C		4. VAX FORTRAN "BYTE" TYPE IS USED FOR NUM3D TO SIMPLY
C		   THE EXTRACTION OF A SINGLE ASCII VALUE FROM A CHARACTER
C		   STRING.
C
C	MACHINE DEPDENDENT NOTES:
C		1. IOR AND IAND DUE BIT-WISE OR AND AND FUNCTIONS.
C
C **************************************************************************
C
	SUBROUTINE INIT3D(X,Y,Z,XA,YA,ZA,THETA,DDS,SSF,II3D)
C
C	CREATED: DGL 1-AUG-1984
C
C	INITIALIZE 3D PLOTTING ROUTINE
C
C	X,Y,Z	 (R):	VIEWING POINT
C	XA,YA,ZA (R):	ORIGIN POINT (LOOKING AT FROM VIEWING POINT)
C	THETA	 (R):	ROTATION ABOUT AXIS DEFINED BY (X,Y,Z), (XA,YA,ZA) (DEG)
C	DDS	 (R):	PERSPECTIVE SCALE
C	SSF	 (R):	RELATIVE SCALE FACTOR
C	II3D	 (I):	PLOTTING ON FLAG (-1 = OFF)
C
	DIMENSION LAST(4),V0(4),VORG(4),ROT(4,4),VIEW(4,4),TEMP1(4,4)
	COMMON /CPLOT3D/LAST,V0,VORG,ROT,DS,VIEW,TEMP1,SF,I3D
C
	I3D=I3D
	SF=1.0
	IF (SSF.GT.0.0) SF=SSF
	DS=DDS
	IF (DDS.LT.0.0) DS=2.
	DO 20 I=1,4
		DO 10 J=1,4
			ROT(I,J)=0.0
			TEMP1(I,J)=0.0
10			VIEW(I,J)=0.0
		ROT(I,I)=1.0
		TEMP1(I,I)=1.0
		VIEW(I,I)=1.0
		VORG(I)=0.0
		V=0.0
20	CONTINUE
	VIEW(4,1)=-X			! SHIFT ORIGIN TO VIEW POINT
	VIEW(4,2)=-Y
	VIEW(4,3)=-Z
	D=SQRT((X-XA)**2+(Y-YA)**2+(Z-ZA)**2)
	VV=SQRT((Y-YA)**2+(X-XA)**2)
	TEMP1(2,2)=0.0
	TEMP1(3,3)=0.0
	TEMP1(3,2)=1.0
	TEMP1(2,3)=-1.0
	TEMP1(1,1)=-1.0
	CALL MATMUL4(VIEW,VIEW,TEMP1)	! REVERSE Z COORIDINATE
	IF (VV.NE.0.0) THEN
		TEMP1(1,1)=(Y-YA)/VV
		TEMP1(2,2)=1.0
		TEMP1(3,3)=TEMP1(1,1)
		TEMP1(2,3)=0.0
		TEMP1(3,2)=0.0
		TEMP1(3,1)=-(X-XA)/VV
		TEMP1(1,3)=-TEMP1(3,1)
		CALL MATMUL4(VIEW,VIEW,TEMP1)	! ROTATE ABOUT Y AXIS
	ENDIF
	IF (D.NE.0.0) THEN
		TEMP1(3,1)=0.0
		TEMP1(1,3)=0.0
		TEMP1(1,1)=1.0
		TEMP1(2,2)=VV/D
		TEMP1(2,3)=-(Z-ZA)/D
		TEMP1(3,2)=-TEMP1(2,3)
		TEMP1(3,3)=TEMP1(2,2)
		CALL MATMUL4(VIEW,VIEW,TEMP1)	! ROTATE ABOUT X AXIS
	ENDIF
	IF (THETA.NE.0.0) THEN
		CALL ROTEM(3,THETA,TEMP1)
		CALL MATMUL4(VIEW,VIEW,TEMP1)
	ENDIF
	DO 50 I=1,4
		DO 40 J=1,4
			TEMP1(I,J)=0.0
40		CONTINUE
		TEMP1(I,I)=1.0
50	CONTINUE
	IF (DS.GT.0.0) THEN
		TEMP1(1,1)=DS
		TEMP1(2,2)=DS
		CALL MATMUL4(VIEW,VIEW,TEMP1)	! xN  CLIPPING WINDOW
	ENDIF
	RETURN
	END
C
	INTEGER FUNCTION IPCLP3(V1,V2)
C
C	CLIPS A 3D LINE FROM V1 TO V2 TO A VIEWING PYRAMID
C
C	RETURN CODE:	-1	INVISIBLE LINE
C			 0	FULLY VISIBLE LINE
C			 1	CLIPPED FIRST POINT OFF
C			 2	CLIPPED SECOND POINT OFF
C			 3	CLIPPED BOTH ENDS OFF
C
	DIMENSION V1(4),V2(4)
	INTEGER CLIP3D,B1,B2,B,IPC
C
	B1=CLIP3D(V1(1),V1(2),V1(3))
	B2=CLIP3D(V2(1),V2(2),V2(3))
	IPC=0
100	IF (IOR(B1,B2).NE.0) THEN
		IF (IAND(B1,B2).NE.0) THEN	! INVISIBLE LINE
			IPC=-1
			GOTO 1000
		ENDIF
		B=B1
		IF (B.EQ.0) B=B2
		IF (IAND(B,1).NE.0) THEN	! CLIP LEFT
			T=(V1(3)+V1(1))/((V1(1)-V2(1))-(V2(3)-V1(3)))
			Z=T*(V2(3)-V1(3))+V1(3)
			X=-Z
			Y=T*(V2(2)-V1(2))+V1(2)
		ENDIF
		IF (IAND(B,2).NE.0) THEN	! CLIP RIGHT
			T=(V1(3)-V1(1))/((V2(1)-V1(1))-(V2(3)-V1(3)))
			Z=T*(V2(3)-V1(3))+V1(3)
			X=Z
			Y=T*(V2(2)-V1(2))+V1(2)
		ENDIF
		IF (IAND(B,4).NE.0) THEN	! CLIP BOTTOM
			T=(V1(3)+V1(2))/((V1(2)-V2(2))-(V2(3)-V1(3)))
			Z=T*(V2(3)-V1(3))+V1(3)
			X=T*(V2(1)-V1(1))+V1(1)
			Y=-Z
		ENDIF
		IF (IAND(B,8).NE.0) THEN	! CLIP TOP
			T=(V1(3)-V1(2))/((V2(2)-V1(2))-(V2(3)-V1(3)))
			Z=T*(V2(3)-V1(3))+V1(3)
			X=T*(V2(1)-V1(1))+V1(1)
			Y=Z
		ENDIF
		IF (B.EQ.B1) THEN
			IPC=IPC+1
			V1(1)=X
			V1(2)=Y
			V1(3)=Z
			B1=CLIP3D(X,Y,Z)
		ELSE
			IPC=IPC+2
			V2(1)=X
			V2(2)=Y
			V2(3)=Z
			B2=CLIP3D(X,Y,Z)
		ENDIF
		GOTO 100
	ENDIF
1000	IPCLP3=IPC
	RETURN
	END
C
C
	INTEGER FUNCTION CLIP3D(X,Y,Z)
C
C	CREATED: DGL 1-AUG-1984
C
C	RETURNS A CODE INDICATING THE LOCATION OF THE POINT (X,Y,Z)
C	IN VIEWING PYRAMID
C
C		1001 | 1000 | 1010
C		------------------
C		0001 | 0000 | 0010
C		------------------
C		0101 | 0100 | 0100
C
	INTEGER C
	C=0
	IF (X.LT.-Z) THEN
		C=1
	ELSE 
		IF (X.GT.Z) C=2
	ENDIF
	IF (Y.LT.-Z) THEN
		C=IOR(C,4)
	ELSE
		IF (Y.GT.Z) C=IOR(C,8)
	ENDIF
	CLIP3D=C
	RETURN
	END
C
C
	SUBROUTINE PLOT3D(X,Y,Z,ID)
C
C	CREATED: DGL 1-AUG-1984
C
C	PLOTS A 3D LINE WITH PERSPECTIVE
C
C	X,Y,Z	(R):	POINT LOCATION
C	ID	(I):	PLOT COMMAND
C			 0 = CHANGE COLOR (X), AND ANGLE (Y) OF PLOT PACKAGE
C			 1 = CHANGE RELATIVE ROTATION MATRIX
C			-1 = CHANGE RELATIVE SCALE FACTOR BY X
C			-2 = PLOT TO X,Y,Z PEN DOWN NEW ORG
C			 2 = PLOT TO X,Y,Z PEN DOWN
C			-3 = MOVE TO X,Y,Z PEN UP NEW ORG
C			 3 = MOVE TO X,Y,Z PEN UP
C			-9 = ERASE TO X,Y,Z PEN DOWN NEW ORG
C			 9 = ERASE TO X,Y,Z PEN DOWN
C
	DIMENSION LAST(4),V0(4),VORG(4),ROT(4,4),VIEW(4,4),TEMP1(4,4)
	COMMON /CPLOT3D/LAST,V0,VORG,ROT,DS,VIEW,TEMP1,SF,I3D
	DIMENSION V1(4),V2(4),V3(4)
C
	V1(1)=X
	V1(2)=Y
	V1(3)=Z
	V1(4)=1.0
	CALL MTV4(V1,ROT,V1)	! ROTATE AROUND LOCAL ORIGIN
	V2(1)=(V1(1)-VORG(1))*SF! SHIFT ORIGIN TO WORLD COORINDATES
	V2(2)=(V1(2)-VORG(2))*SF
	V2(3)=(V1(3)-VORG(3))*SF
	V2(4)=1.0
	CALL MTV4(V1,VIEW,V2)	! xVN
	IF (DS.EQ.0.0.OR.V1(3).EQ.0.0) THEN
		CALL VCPY(LAST,V1)
	ELSE
		LAST(1)=V1(1)/V1(3)
		LAST(2)=V1(2)/V1(3)
		LAST(3)=1./V1(3)
		LAST(4)=V1(4)
	ENDIF
	IF (IABS(ID).GT.9) RETURN
	GOTO (5,10,20,30,40,40,40,40,40,20) IABS(ID)+1
 5	CONTINUE		! ID = 0
	CALL PLOT(X,Y,0)	! CHANGE COLOR
	IF (Z.GT.0.) DS=DS*Z
	RETURN
10	CONTINUE		! ID = 1
	IF (ID.GT.0) THEN	! CHANGE ROTATION MATRIX
		CALL ROTEM(1,X,TEMP1)
		CALL MATMUL4(ROT,ROT,TEMP1)
		CALL ROTEM(2,Y,TEMP1)	
		CALL MATMUL4(ROT,ROT,TEMP1)
		CALL ROTEM(3,Z,TEMP1)
		CALL MATMUL4(ROT,ROT,TEMP1)
	ELSE			! CHANGE SCALE FACTOR
		SF=X*SF
		IF (SF.LE.0.0) SF=1.0
	ENDIF
20	CONTINUE		! ID = 2,9
	IF (ID.LT.0) CALL VCPY(VORG,V2)
	CALL VCPY(V2,V0)
	CALL VCPY(V3,V1)
	IF (I3D.NE.-1) THEN
		IFLAG=IPCLP3(V2,V3) ! 3D PERSPECTIVE CLIPPING
		IF (IFLAG.NE.-1) CALL DRAW3D(V2,V3,IABS(ID),DS,IFLAG)
	ENDIF
	CALL VCPY(V0,V1)
	RETURN
30	CONTINUE		! ID = 3
	IF (ID.LT.0) CALL VCPY(VORG,V2)
	CALL VCPY(V0,V1)
40	RETURN
	END
C
C
	SUBROUTINE DRAW3D(V1,V2,ID,DS,IFLAG)
C
C	CREATED: DGL 1-AUG-1984
C
C	PLOT A LINE FROM V1 TO V2 WITH PERSPECTIVE
C
C	V1,V2	(R):	LINE DEFINED BETWEEN TWO SCREEN COORDINATE POINTS
C	ID	(I):	PLOT CODE (2,9)
C	DS	(R):	PERSPECTIVE SCALE FACTOR (DS=0 NO PERSPECTIVE)
C	IFLAG	(I):	CLIP CODE
C
	DIMENSION V1(4),V2(4)
	COMMON /LAST3D/XS2,YS2,XS1,YS1
	IF (DS.NE.0.0) THEN	! PERSPECTIVE
		IF (V1(3).EQ.0.0.OR.V2(3).EQ.0.0) THEN
			RETURN	! LINE THROUGH Ze PLANE
		ELSE
			XS1=(V1(1)/V1(3))	!/DS
			YS1=(V1(2)/V1(3))	!/DS
			CALL PLOT(XS1,YS1,3)
			XS2=(V2(1)/V2(3))	!/DS
			YS2=(V2(2)/V2(3))	!/DS
			CALL PLOT(XS2,YS2,ID)
C			CALL PLOT(XS2,YS2,3)
		ENDIF
	ELSE			! NO PERSPECTIVE
		XS1=V1(1)
		YS1=V1(2)
		CALL PLOT(XS1,YS1,3)
		XS2=V2(1)
		YS2=V2(2)
		CALL PLOT(XS2,YS2,ID)
C		CALL PLOT(XS2,YS2,3)
	ENDIF
	RETURN
	END
C
C
	SUBROUTINE WHERE3D(X,Y)
C
C	CREATED: DGL 1-AUG-1984
C
C	RETURNS THE X,Y SCREEN LOCATIONS OF THE LAST CALL TO
C	DRAW3D (FROM PLOT3D)
C
	COMMON /LAST3D/XS2,YS2,XS1,YS1
	X=XS2
	Y=YS2
	RETURN
	END
C
C
	SUBROUTINE VCPY(V1,V2)
C
C	CREATED: DGL 1-AUG-1984
C
C	COPIES A FOUR ELEMENT VECTOR FROM V2 TO V1
C
	DIMENSION V1(4),V2(4)
	DO 10 I=1,4
		V1(I)=V2(I)
10	CONTINUE
	RETURN	
	END
C
C
	SUBROUTINE MTV4(V2,R,V1)
C
C	CREATED: DGL 1-AUG-1984
C
C	MULTIPLIES VECTOR V1 TIMES MATRIX R AND STORES RESULT INTO V2
C	V2 CAN BE V1 (CAN BE DONE IN PLACE) V2 = V1*R
C
	DIMENSION V2(4),R(4,4),V1(4),V3(4)
	DO 20 K=1,4
		V3(K)=0.0
		DO 10 I=1,4
			V3(K)=V3(K)+V1(I)*R(I,K)
10		CONTINUE
20	CONTINUE
	DO 30 I=1,4
		V2(I)=V3(I)
30	CONTINUE
	RETURN
	END
C
C
	SUBROUTINE ROTEM(IROT,ANG,R)
C
C	CREATED: DGL 1-AUG-1984
C
C	CREATES 3 AXIS ROTATION MATRIX
C
C	R	RESULT MATRIX R(4,4)
C	IROT	AXIS OF ROTATION
C		= 1  X AXIS
C		= 2  Y AXIS
C		= 3  Z AXIS
C	ANG	ANGLE OF ROTATION IN DEGREES
C
	DIMENSION R(4,4)
	X=ANG*3.141592654/180.
	IF (ANG.EQ.0.0) THEN
		C=1.0
		S=0.0
	ELSE IF (ABS(ANG).EQ.90.0) THEN
		C=0.0
		S=1.0*SIGN(1.,ANG)
	ELSE
		C=COS(X)
		S=SIN(X)
	ENDIF
	DO 10 I=1,4
		DO 20 J=1,4
			R(I,J)=0.
 20		CONTINUE
 10	CONTINUE
	IF (IROT .NE. 1) GO TO 200
	R(2,2)=C
	R(3,2)=-S
	R(2,3)=S
	R(3,3)=C
	R(1,1)=1.
	R(4,4)=1.
	RETURN
 200	IF (IROT .NE. 2) GO TO 300
	R(1,1)=C
	R(3,1)=S
	R(1,3)=-S
	R(3,3)=C
	R(2,2)=1.
	R(4,4)=1.
	RETURN
 300	R(1,1)=C
	R(2,1)=-S
	R(1,2)=S
	R(2,2)=C
	R(3,3)=1.
	R(4,4)=1.
	RETURN
	END
C
C
	SUBROUTINE MATMUL4(R,A,B)
C
C	CREATED: DGL 1-AUG-1984
C
C	THIS SUBROUTINE MULTIPLIES TWO 4X4 MATRICES A X B = R
C	A CAN BE C (IN PLACE)
C
C	R	RESULT MATRIX DIMENSIONED R(4,4)
C	A	INPUT MATRIX DIMENSIONED A(4,4)
C	B	INPUT MATRIX DIMENSIONED B(4,4)
C
	DIMENSION A(4,4),B(4,4),R(4,4),V(4)
	DO 20 J=1,4
		DO 10 K=1,4
			V(K)=0.0
			DO 5 I=1,4
				V(K)=V(K)+A(J,I)*B(I,K)
 5			CONTINUE
10		CONTINUE
		DO 15 K=1,4
			R(J,K)=V(K)
15		CONTINUE
20	CONTINUE
	RETURN
	END
C
C
      SUBROUTINE SYM3D(XA,YA,ZA,PA,PB,PG,HI,ASC,NC)
C
C	CREATED: DGL 1-OCT-1984
C	
C	PLOTS SYMBOLS IN 3-D USING PLOT3D
C
C	XA,YA,ZA COORDINATES OF STRING LOWER-LEFT CORNER
C		  (999.,999.,999.) CONTINUE FROM LAST POINT
C	PA,PB	SPECIFIES THE PROJECTED ANGLES (IN DEGS) RELATIVE TO THE
C		 X-Y PLANE AND THE X-Z PLANE OF THE LINE ALONG THE
C		 BASE OF THE PLOTTED NUMBER SEQUENCE
C	PG	SPECIFIES THE ROTATION OF THE PLOTTED SYMBOLS AROUND
C		THE LINE SPECIFIED BY PA,PB
C	HI	HEIGHT OF THE PLOTTED CHARACTERS
C	ASC	STING ARRAY CONTAINING CHARACTERS TO BE PLOTTED
C	NC	NUMBER OF CHARACTERS TO BE PLOTTED
C
      INTEGER ASC(1)
      INTEGER*2 SYM(128),STB(416)
      INTEGER*2 SYN  1(8)
      INTEGER*2 SYN  9(8)
      INTEGER*2 SYN 17(8)
      INTEGER*2 SYN 25(8)
      INTEGER*2 SYN 33(8)
      INTEGER*2 SYN 41(8)
      INTEGER*2 SYN 49(8)
      INTEGER*2 SYN 57(8)
      INTEGER*2 SYN 65(8)
      INTEGER*2 SYN 73(8)
      INTEGER*2 SYN 81(8)
      INTEGER*2 SYN 89(8)
      INTEGER*2 SYN 97(8)
      INTEGER*2 SYN105(8)
      INTEGER*2 SYN113(8)
      INTEGER*2 SYN121(8)
      INTEGER*2 STC  1(8)
      INTEGER*2 STC  9(8)
      INTEGER*2 STC 17(8)
      INTEGER*2 STC 25(8)
      INTEGER*2 STC 33(8)
      INTEGER*2 STC 41(8)
      INTEGER*2 STC 49(8)
      INTEGER*2 STC 57(8)
      INTEGER*2 STC 65(8)
      INTEGER*2 STC 73(8)
      INTEGER*2 STC 81(8)
      INTEGER*2 STC 89(8)
      INTEGER*2 STC 97(8)
      INTEGER*2 STC105(8)
      INTEGER*2 STC113(8)
      INTEGER*2 STC121(8)
      INTEGER*2 STC129(8)
      INTEGER*2 STC137(8)
      INTEGER*2 STC145(8)
      INTEGER*2 STC153(8)
      INTEGER*2 STC161(8)
      INTEGER*2 STC169(8)
      INTEGER*2 STC177(8)
      INTEGER*2 STC185(8)
      INTEGER*2 STC193(8)
      INTEGER*2 STC201(8)
      INTEGER*2 STC209(8)
      INTEGER*2 STC217(8)
      INTEGER*2 STC225(8)
      INTEGER*2 STC233(8)
      INTEGER*2 STC241(8)
      INTEGER*2 STC249(8)
      INTEGER*2 STC257(8)
      INTEGER*2 STC265(8)
      INTEGER*2 STC273(8)
      INTEGER*2 STC281(8)
      INTEGER*2 STC289(8)
      INTEGER*2 STC297(8)
      INTEGER*2 STC305(8)
      INTEGER*2 STC313(8)
      INTEGER*2 STC321(8)
      INTEGER*2 STC329(8)
      INTEGER*2 STC337(8)
      INTEGER*2 STC345(8)
      INTEGER*2 STC353(8)
      INTEGER*2 STC361(8)
      INTEGER*2 STC369(8)
      INTEGER*2 STC377(8)
      INTEGER*2 STC385(8)
      INTEGER*2 STC393(8)
      INTEGER*2 STC401(8)
      INTEGER*2 STC409(8)
      EQUIVALENCE (SYM(  1),SYN  1(1))
      EQUIVALENCE (SYM(  9),SYN  9(1))
      EQUIVALENCE (SYM( 17),SYN 17(1))
      EQUIVALENCE (SYM( 25),SYN 25(1))
      EQUIVALENCE (SYM( 33),SYN 33(1))
      EQUIVALENCE (SYM( 41),SYN 41(1))
      EQUIVALENCE (SYM( 49),SYN 49(1))
      EQUIVALENCE (SYM( 57),SYN 57(1))
      EQUIVALENCE (SYM( 65),SYN 65(1))
      EQUIVALENCE (SYM( 73),SYN 73(1))
      EQUIVALENCE (SYM( 81),SYN 81(1))
      EQUIVALENCE (SYM( 89),SYN 89(1))
      EQUIVALENCE (SYM( 97),SYN 97(1))
      EQUIVALENCE (SYM(105),SYN105(1))
      EQUIVALENCE (SYM(113),SYN113(1))
      EQUIVALENCE (SYM(121),SYN121(1))
      EQUIVALENCE (STB(  1),STC  1(1))
      EQUIVALENCE (STB(  9),STC  9(1))
      EQUIVALENCE (STB( 17),STC 17(1))
      EQUIVALENCE (STB( 25),STC 25(1))
      EQUIVALENCE (STB( 33),STC 33(1))
      EQUIVALENCE (STB( 41),STC 41(1))
      EQUIVALENCE (STB( 49),STC 49(1))
      EQUIVALENCE (STB( 57),STC 57(1))
      EQUIVALENCE (STB( 65),STC 65(1))
      EQUIVALENCE (STB( 73),STC 73(1))
      EQUIVALENCE (STB( 81),STC 81(1))
      EQUIVALENCE (STB( 89),STC 89(1))
      EQUIVALENCE (STB( 97),STC 97(1))
      EQUIVALENCE (STB(105),STC105(1))
      EQUIVALENCE (STB(113),STC113(1))
      EQUIVALENCE (STB(121),STC121(1))
      EQUIVALENCE (STB(129),STC129(1))
      EQUIVALENCE (STB(137),STC137(1))
      EQUIVALENCE (STB(145),STC145(1))
      EQUIVALENCE (STB(153),STC153(1))
      EQUIVALENCE (STB(161),STC161(1))
      EQUIVALENCE (STB(169),STC169(1))
      EQUIVALENCE (STB(177),STC177(1))
      EQUIVALENCE (STB(185),STC185(1))
      EQUIVALENCE (STB(193),STC193(1))
      EQUIVALENCE (STB(201),STC201(1))
      EQUIVALENCE (STB(209),STC209(1))
      EQUIVALENCE (STB(217),STC217(1))
      EQUIVALENCE (STB(225),STC225(1))
      EQUIVALENCE (STB(233),STC233(1))
      EQUIVALENCE (STB(241),STC241(1))
      EQUIVALENCE (STB(249),STC249(1))
      EQUIVALENCE (STB(257),STC257(1))
      EQUIVALENCE (STB(265),STC265(1))
      EQUIVALENCE (STB(273),STC273(1))
      EQUIVALENCE (STB(281),STC281(1))
      EQUIVALENCE (STB(289),STC289(1))
      EQUIVALENCE (STB(297),STC297(1))
      EQUIVALENCE (STB(305),STC305(1))
      EQUIVALENCE (STB(313),STC313(1))
      EQUIVALENCE (STB(321),STC321(1))
      EQUIVALENCE (STB(329),STC329(1))
      EQUIVALENCE (STB(337),STC337(1))
      EQUIVALENCE (STB(345),STC345(1))
      EQUIVALENCE (STB(353),STC353(1))
      EQUIVALENCE (STB(361),STC361(1))
      EQUIVALENCE (STB(369),STC369(1))
      EQUIVALENCE (STB(377),STC377(1))
      EQUIVALENCE (STB(385),STC385(1))
      EQUIVALENCE (STB(393),STC393(1))
      EQUIVALENCE (STB(401),STC401(1))
      EQUIVALENCE (STB(409),STC409(1))
      DATA SYN	1/     0,     8,    20,    26
     1,    31,	  36,	 43,	50/
      DATA SYN	9/    55,    62,    68,    82
     1,    91,	  98,	101,   104/
      DATA SYN 17/   111,   118,   125,   125
     1,   125,	 125,	125,   125/
      DATA SYN 25/   125,   125,   125,   125
     1,   125,	 125,	125,   125/
      DATA SYN 33/   125,   126,   136,   141
     1,   150,	 161,	174,   186/
      DATA SYN 41/   190,   195,   200,   207
     1,   212,	 215,	218,   221/
      DATA SYN 49/   223,   234,   240,   249
     1,   260,	 266,	276,   287/
      DATA SYN 57/   293,   311,   321,   326
     1,   332,	 336,	341,   345/
      DATA SYN 65/   354,   366,   373,   385
     1,   394,	 402,	409,   414/
      DATA SYN 73/   424,   430,   437,   443
     1,   448,	 452,	457,   463/
      DATA SYN 81/   473,   480,   492,   501
     1,   514,	 519,	526,   530/
      DATA SYN 89/   536,   544,   552,   559
     1,   564,	 567,	571,   577/
      DATA SYN 97/   583,   586,   597,   607
     1,   614,	 625,	635,   641/
      DATA SYN105/   654,   660,   668,   675
     1,   681,	 687,	697,   704/
      DATA SYN113/   714,   724,   735,   740
     1,   748,	 754,	762,   766/
      DATA SYN121/   772,   776,   785,   790
     1,   798,	 803,	811,   816/
      DATA STC	1/ 10842,  2088, 11276, -9686
     1, 10842,	8233,  2320,  5131/
      DATA STC	9/ 11044, -9686, 10842,  3080
     1, -9686,	2666,  7256, 18650/
      DATA STC 17/ 26668, -9716, 10842,  2584
     1, 10780, 23258, 10776,  6684/
      DATA STC 25/ -9718, 11336,  3112, 26842
     1,  2092, 22796, -9701, 10330/
      DATA STC 33/  6764, -9718, 11354,  8547
     1, 24872,	2065,  4945, 21260/
      DATA STC 41/ -9693, 11336,  3176, 10826
     1,  7256, 23258, 11304,  3080/
      DATA STC 49/ -9702, 10826, 22746, -9700
     1,  7256, 11368,  3144, 24794/
      DATA STC 57/ 20516, 18708, -9685, 10842
     1,  9057,	4945,-14630,   577/
      DATA STC 65/  2314, 20993, 12849,-14830
     1, 12641,	9075, 16838, 29489/
      DATA STC 73/ 24579, 21540,-14832,  2888
     1,  6932,	8217, 11305,   626/
      DATA STC 81/ 18630, 26924, 12328, 10545
     1,   836,	3083,-14844,   596/
      DATA STC 89/  2049,  8976, 12843,  6441
     1,-14844, 10849,-14798,  8563/
      DATA STC 97/   785, 29126,  4899,-14847
     1, 10826,	4196,  5216, 19142/
      DATA STC105/ 22570,-14820,  4361, 22726
     1,-14820,	 321, 13510, 18630/
      DATA STC113/ 12584, 11315,   780,  2049
     1,-14804,	 833, 12866,-14807/
      DATA STC121/ 12648, 11315,  2084,  1024
     1, 28870, 11316,  6938,  3092/
      DATA STC129/   259,-14840, 13123,  4120
     1,-14828,	 328,  3075,  8988/
      DATA STC137/ 12320,-14796,  7000,  3092
     1,   259,	8200, 13362, 28870/
      DATA STC145/ 11316,   273, 16838,  3075
     1,  6932,	8217, 12584, 11315/
      DATA STC153/  6948,  4185,   264,   710
     1, 11284, 12595,  8232,  7193/
      DATA STC161/ 16838, 20737,-14831,  2625
     1, 25106,-14814,  6211,-14797/
      DATA STC169/  5200,  8292, 16838, 12572
     1, 17094, 20994, 11300, 12595/
      DATA STC177/-14808,   323, 10248, 13105
     1,  5164,	6674,-14804, 12832/
      DATA STC185/  1060,  5200, 12486, 11315
     1,  6948, 23320,  3092,	 3/
      DATA STC193/ 27846, 12595,  2088,   769
     1,-14836,	3075, 13100, 28976/
      DATA STC201/-14847, 13360,  6235,  1088
     1, 12486, 23092,-14824, 13164/
      DATA STC209/ 10289,   264,  5124,-14829
     1, 22576, 29724,-14844,   833/
      DATA STC217/ 12866, 13169, 18630,   769
     1, 13324, 12486,  6260,-14844/
      DATA STC225/ 16432,-14844,  6704,  1076
     1, 12486,	3176,  1140, 18630/
      DATA STC233/   769, 11276, 12595,  2088
     1, 12486, 11315,  6948,-14824/
      DATA STC241/   328,  3075, 13100, 10289
     1, 21000,-14844, 13104,  9260/
      DATA STC249/  6171,  1114, 18630,   769
     1,  5132,	6427, 10272, 13105/
      DATA STC257/-14804, 13424,   626, 28870
     1,   264,	3075,-14796,   624/
      DATA STC265/-14796,   368,   794,-14796
     1, 11272, 28724,  3112,-14844/
      DATA STC273/ 10352,   538, 11380,-14822
     1, 13424,	2092,  1024, 29382/
      DATA STC281/    48,-15358, 12356,   710
     1, 12338, 22724,  7210,  2666/
      DATA STC289/ 19142, 10776,  7256, 28870
     1,-14821,	6216,  8737,   532/
      DATA STC297/  2049,  1124, 12486,  8784
     1,  7203,	 780,  4098, 25798/
      DATA STC305/  6177,   264,-14844,  1140
     1,  8788,	6177,	264,  5122/
      DATA STC313/ 20678,  7188,  8483,  2072
     1,   769, 17094, 13098,  7001/
      DATA STC321/ 16838,  3075, 25652, 12594
     1,  6184,	4625,-14812, 24624/
      DATA STC329/  7203,-14844,   833,  6722
     1, 27161,-14806,	577,  8971/
      DATA STC337/ 13171, 12486,  2156,  1114
     1, 16838, 16899, 12594,  8390/
      DATA STC345/  8536,   538,  9050,  1052
     1,  8390,	8536,  7203,-14844/
      DATA STC353/  6216,  8993,  3100,   259
     1,-14840, 24624, 13106,  7212/
      DATA STC361/  4627,-14816, 13380, 12900
     1, 10289,	4376,  9234,  8390/
      DATA STC369/  8784,-14812,  3075,  4371
     1,  8472,-14812,  9057,  2674/
      DATA STC377/-14845,  2144,   769, 25612
     1,-14844,	 608,-14812,   352/
      DATA STC385/   786,-14812, 24612,-14844
     1,   833, 13324,  6256,  5137/
      DATA STC393/ 24774,    36,-14844,  2370
     1,  6161, 10529,-15054,  4674/
      DATA STC401/ 12898, 16838,  4618,  8731
     1, 12586, 20677,  6937,-14812/
      DATA STC409/ 13360,     4, 28724,-14844
     1,     0,	   0,	  0,	 0/
C
	DIMENSION ROT(4,4),TEMP(4,4),V(4)
C
	XA1=XA
	YA1=YA
	ZA1=ZA
	IF (XA.EQ.999..OR.YA.EQ.999..OR.ZA.EQ.999.) THEN !CONTINUE STRING OUTPUT
		XA1=X
		YA1=Y
		ZA1=Z
	ELSE
C
C	SET UP 3-D CONVERSION MATRIXES
C
		CALL ROTEM(1,PG,ROT)
		CALL ROTEM(3,PB,TEMP)
		CALL MATMUL4(ROT,ROT,TEMP)
		CALL ROTEM(2,PA,TEMP)
		CALL MATMUL4(ROT,ROT,TEMP)
	ENDIF
	X=XA1
	Y=YA1
	Z=ZA1
C
	H=HI/7.0
	IF (NC.NE.-2) GOTO 4
	IP=2
	CALL PLOT3D(XA1,YA1,Z,IP)
4	IP=3
	CALL PLOT3D(X,Y,Z,IP)
	IF (NC) 10,20,30
10	NC0=0
C
C	PUT FIRST CHARACTER OF ASC INTO JCH
C
	CALL PXPCGT(ASC,1,JCH)
	GOTO 50
20	RETURN
30	NC0=NC
	I0=0
40	NC0=NC0-1
	IF (NC0.LT.0) GOTO 20
	I0=1+I0
C
C	PUT THE I0 CHARACTER OF ASC INTO JCH
C
	CALL PXPCGT(ASC,I0,JCH)
50	IF (JCH.LT.0.OR.JCH.GE.128) JCH=32
	I3=SYM(1+JCH)
	IF (JCH.GE.32) GOTO 55
C	CENTERED PLOTTING SYMBOLS
	IP=3
	I1=0
	V(1)=-H*2.
	V(2)=-H*3.
	V(3)=0.
	CALL MTV4(V,ROT,V)
	X=V(1)+X
	Y=V(2)+Y
	Z=V(3)+Z
	XW1=0.
	YW1=0.
	XW2=0.
	YW2=0.
	GOTO 110
55	IF (JCH.NE.112) GOTO 60
	XW2=0.
	YW2=-H*2.
	V(1)=XW2
	V(2)=YW2
	V(3)=0.0
	CALL MTV4(V,ROT,V)
	CALL PLOT3D(V(1)+X,V(2)+Y,V(3)+Z,3)
60	IP=2
	I3=1+I3
	I4=(I3-1)/2+1
	IV=STB(I4)
	IJ=MOD(I3-1,2)*8
	I1=IBITS(IV,IJ,8)
	I2=MOD(I1,64)
	IF (I1.GE.64) IP=3
	IY=I2/8
	IX=I2-8*IY
	X1=IX
	Y1=IY
	XW1=H*X1
	YW1=H*Y1
	XW2=XW1
	YW2=YW1
	IF ((JCH.EQ.103.OR.JCH.EQ.112.OR.JCH.EQ.113.OR.
     $		JCH.EQ.121).AND.(I1.LT.192)) THEN
		XW2=XW2
		YW2=YW2-H*2.
	ENDIF
110	CONTINUE
	V(1)=XW2
	V(2)=YW2
	V(3)=0.0
	CALL MTV4(V,ROT,V)
	CALL PLOT3D(V(1)+X,V(2)+Y,V(3)+Z,IP)
	IF (I1.LT.192) GOTO 60
	V(1)=XW1
	V(2)=YW1
	V(3)=0.0
	CALL MTV4(V,ROT,V)
	X=V(1)+X
	Y=V(2)+Y
	Z=V(3)+Z
	GOTO 40
	END
C
C
	SUBROUTINE NUM3D(XA,YA,ZA,PA,PB,PG,HGHT,Z,F0)
C
C	CREATED: DGL 1-OCT-1984
C	
C	PLOTS A FLOATING POINT NUMBER IN 3-D USING SYM3D
C
C	XA,YA,ZA COORDINATES OF STRING LOWER-LEFT CORNER
C		  (999.,999.,999.) CONTINUE FROM LAST POINT
C	PA,PB	SPECIFIES THE PROJECTED ANGLES (IN DEGS) RELATIVE TO THE
C		 X-Y PLANE AND THE X-Z PLANE OF THE LINE ALONG THE
C		 BASE OF THE PLOTTED NUMBER SEQUENCE
C	PG	SPECIFIES THE ROTATION OF THE PLOTTED SYMBOLS AROUND
C		THE LINE SPECIFIED BY PA,PB
C	HGHT	HEIGHT OF THE PLOTTED NUMBER
C	Z	FLOATING POINT NUMBER TO BE PLOTTED
C	F0	PLOTTING FORMAT (Fn.j)
C		  n = TOTAL NUMBER OF SPACES TO USE (INCLUDING SIGN AND D.P.)
C			[MAX 18 CHARACTERS WIDE]
C		  j = DIGITS TO RIGHT OF DECIMAL POINT (2 DIGITS)
C		  F0 < 0 SPECIFIES EXPONENTIAL NOTATION
C		  F0 = PLOT INTEGER PORTION ONLY WITH NO D.P. (FREE FORMAT)
C		  F0 > 1000 PLOT INTEGER PORTION IN FIXED FORMAT
C		  IF n=0 THEN J IS NUMBER OF DIGITS TO RIGHT OF DECIMAL POINT
C		  WHEN Z OVERFLOWS THIS FORMAT, SPACE IS FILLED WITH ASTERICKS
C NOTE:
C	F0 IS SET UP TO HANDLE AN INTEGER ARGUMENT (MACHINE DEPENDENT)
C		(NUMBER OF DIGITS TO RIGHT OF DECIMAL POINT)
C
	BYTE B(18)
	EQUIVALENCE (NN,RR)
	ND=-1
	XT=XA
	YT=YA
	ZT=ZA
	PAT=PA
	PBT=PB
	PGT=PG
	HG=HGHT
	FA=F0
	IF (FA.NE.0.0) GOTO 3
	RR=FA
	IF (NN.NE.0) GOTO 2		! CHECK FOR INTEGER F0 INPUT
    	ND=0
	FA=1.0
	GOTO 5
  1	NN=AMOD(FA,1000.)		! PLOT FORMATED INTEGER 
	FA=0.
	GOTO 5
  2	FA=1.0
	IF (NN.LT.0) FA=0.0
	ND=NN
	NN=0
	GOTO 5
  3	IF (ABS(FA).GT.1.E30)  THEN
		RR=FA
		GOTO 2			! INTEGER -1 INPUT
	ENDIF
	IF (FA.GT.999) GOTO 1
	F=ABS(FA)*1.000002		! GET PLOT FORMAT
	NN=F
	F=(F-NN)*100.
	ND=F
  5	IF (ND.GT.17) ND=ND/10		! SOLVE SIMPLE ERRORS
	IF (NN.EQ.0) THEN		! DIGITS TO LEFT OF DECIMAL POINT
		NN=ND+2
		IF (Z.EQ.0.AND.FA.EQ.0.0) NN=1
		IF (Z.NE.0.) THEN
			ALG=ALOG10(ABS(Z))
			IF (ALG.LT.0.0) ALG=0.
			NN=ND+2+ALG
		ENDIF
		IF (Z.LT.0.0) NN=NN+1
		IF (FA.LT.0.0) NN=NN+4
	ENDIF
	IF (ND.GT.NN) GOTO  60		! FORMAT ERROR
	IF (NN.GT.18) NN=18		! MAX CHARACTERS
	IF (FA) 20,30,40
 20	ENCODE(18,21,B,ERR=90) Z
 21	FORMAT(E<NN>.<ND>)
	GOTO 50
 30	I=Z
	ENCODE(18,31,B,ERR=90) I
 31	FORMAT(I<NN>)
	GOTO 50
 40	ENCODE(18,41,B,ERR=90) Z
 41	FORMAT(F<NN>.<ND>)
 50	CALL SYM3D(XT,YT,ZT,PAT,PBT,PGT,HG,B,NN)
 60	RETURN
 90	DO 95 I=1,18
		B(I)='*'
		IF (I.EQ.NN-ND) B(I)='.'
 95	CONTINUE
	GOTO 50
	END
C
C
	SUBROUTINE AXIS3D(X0,Y0,Z0,PA,PB,PG,T,N0,S0,B0,C0,D0,E0,F0)
C
C	CREATED: DGL 1-OCT-1984
C
C	X0	X COORDINATE OF START OF AXIS
C	Y0	Y COORDINATE OF START OF AXIS
C	Z0	Z COORDINATE OF START OF AXIS
C	T	CHARACTER STRING TO DESCRIBE AXIS
C	PA	ANGLE FROM X-Y PLANE (DEG)
C	PB	ANGLE FROM X-Z PLANE (DEG)
C	PG	ANGLE OF ROTATION AROUND PA,PB RAY (DEG)
C	N0	NUMBER OF CHARACTERS IN STRING
C		- ON CLOCKWISE SIDE OF AXIS (NORMAL FOR X)
C		+ ON COUNTER CLOCKWISE SIDE OF AXIS (NORMAL FOR Y)
C		HUNDREDS DIGIT	= 1 NO LABELING OF AXIS--TICKS AND LINE ONLY
C	S0	LENGTH OF AXIS IN INCHES
C		< 0	TICKS PLACED ON OPPOSITE SIDE OF AXIS LABEL
C		= 0	NO ACTION (NOP)
C		> 0	NORMAL
C	B0	MINIMUM VALUE ON TICK AXIS
C	C0	MAXIMUM VALUE ON TICK AXIS
C	D0	INT(D0) = NUMBER OF MAJOR AXIS TICKS
C		INT((INT(D0)-D0)*100) = NUMBER OF MINOR AXIS TICKS BETWEEN MAJOR TICKS
C		INT(MOD((INT(D0)-D0)*10000,100) = NUMBER OF SUB MINOR AXIS TICKS 
C			BETWEEN MINOR TICKS
C	E0	CHARACTER SIZE OF TITLE AND NUMBER (IF E0=0 DEFAULTS TO .15)
C			< 0 THEN DO NOT AUTO SCALE BY (x10 TO POWER)
C	F0	NUMBER SPECIFICATION (FORMAT FX.Y) (2 DIGITS FOR Y, MAX(X)=18)
C
C NOTE:
C
	DIMENSION ROT(4,4),TEMP(4,4),V(4)
	INTEGER T(1)
	DATA SPACE/0.08/		! MIN SPACING BETWEEN ITEMS
	XROT3D(X,Y)=XVMUL3D(1,X,Y,0.0,V,ROT)+X01
	YROT3D(X,Y)=XVMUL3D(2,X,Y,0.0,V,ROT)+Y01
	ZROT3D(X,Y)=XVMUL3D(3,X,Y,0.0,V,ROT)+Z01
C
	TL=0.1				! TICK LENGTH
	X01=X0
	Y01=Y0
	Z01=Z0
	PAA=PA
	PBA=PB
	PGA=PG
	E1=E0				! CHARACTER SIZE
	CS=ABS(E1)
	IF (CS.EQ.0.) CS=.15
	IF (S0.EQ.0.0) GOTO 1000	! ZERO LENGTH AXIS
	X1=D0*1.000002
	NJT=ABS(X1)			! NUMBER OF MAJOR TICKS
	NNT=100.*(ABS(X1)-NJT)		! NUMBER OF MINOR TICKS
	NST=100.*((ABS(X1)-NJT)*100.-NNT)	! NUMBER OF SUB-MINOR TICKS
	IF (NJT.LT.2) NJT=2
	XJ=ABS(S0)/(NJT-1)		! INCREMENT BETWEEN MAJOR TICKS
	XN=XJ
	IF (NNT.NE.0) XN=XN/(NNT+1)	! INCREMENT BETWEEN MINOR TICKS
	XS=XN/(NST+1)			! INCREMENT BETWEEN SUB-MINOR TICKS
	N1=N0
	HOR=0.0
	IF (IABS(N1).GE.1000) HOR=90.	! DEFAULT ROTATION ANGLE
	NC=MOD(IABS(N1),100)		! NUMBER OF CHARACTERS IN TITLE
	FA=F0				! FORMAT NUMBER
	ND=MOD(ABS(FA),1000.)		! NUMBER OF DIGITS
	NG=100.*(MOD(ABS(FA),1000.)-ND)	! NUMBER OF DIGITS RIGHT OF D.P.
	IF (NG.GT.17) NG=NG/10		! CORRECT SIMPLE ERRORS
	IF (ND.EQ.0) ND=NG
	IF (ABS(FA).GT.1000) NG=-1	! FORMATTED INTEGER
	TL1=TL
	IF (S0.LT.0.) TL1=-TL		! REVERSE SIDE OF TICKS
	IF (S0.LT.0.) TL=0.		! REVERSE SIDE OF TICKS
	IF (IABS(N1).GE.1000) GOTO 10
		DNX=-ND*CS/2.		! NUMBER LABEL DISTANCE FROM AXIS
		DNY=-TL-SPACE-CS	! NUMBER LABEL DISTANCE FROM AXIS
		DTY=DNY-CS-SPACE	! TITLE DISTANCE FROM AXIS
		GOTO 20
10	CONTINUE			! HORIZONTAL NUMBERS ON VERTICAL AXIS
		DNX=-CS/2.		! NUMBER LABEL DISTANCE FROM AXIS
		DNY=-TL-SPACE		! NUMBER LABEL DISTANCE FROM AXIS
		DTY=DNY-ND*CS-SPACE	! TITLE DISTANCE FROM AXIS
20	DTX=(ABS(S0)-NC*CS)/2.		! TITLE DISTANCE FROM AXIS
	IF (N1.LT.0) GOTO 30		! CLOCKWISE TITLES
		DNY=-DNY-CS		! COUNTER-CLOCKWISE TITLES
		DTY=-DTY-CS
		TL1=-TL1		! CHANGE SIDES OF TICKS
		IF (IABS(N1).LT.1000) GOTO 30
			DNY=DNY+CS*ND
			DTY=DNY+SPACE
30	CONTINUE
C
C	SET UP 3-D CONVERSION MATRIXES
C
	CALL ROTEM(1,PGA,ROT)
	CALL ROTEM(3,PBA,TEMP)
	CALL MATMUL4(ROT,ROT,TEMP)
	CALL ROTEM(2,PAA,TEMP)
	CALL MATMUL4(ROT,ROT,TEMP)
C
	X1=0.0				! FIRST MAJOR TICK
	Y1=0.0
	Y2=-TL1
	CALL PLOT3D(XROT3D(X1,Y1),YROT3D(X1,Y1),ZROT3D(X1,Y1),3)
	CALL PLOT3D(XROT3D(X1,Y2),YROT3D(X1,Y2),ZROT3D(X1,Y1),2)
	DO 100 I=1,NJT-1		! MAJOR TICKS
		CALL PLOT3D(XROT3D(X1,Y1),YROT3D(X1,Y1),ZROT3D(X1,Y1),3)
		X1=XJ*I
		Y2=-TL1
		CALL PLOT3D(XROT3D(X1,Y1),YROT3D(X1,Y1),ZROT3D(X1,Y1),2)
		CALL PLOT3D(XROT3D(X1,Y2),YROT3D(X1,Y2),ZROT3D(X1,Y2),2)
		DO 110 J=1,NNT+1	! MINOR TICKS
			Y2=-TL1*.7
			X2=X1+XN*J-XJ
		CALL PLOT3D(XROT3D(X2,Y1),YROT3D(X2,Y1),ZROT3D(X2,Y1),3)
		CALL PLOT3D(XROT3D(X2,Y2),YROT3D(X2,Y2),ZROT3D(X2,Y2),2)
			Y2=-TL1*.4
			DO 120 K=1,NST	! SUB MINOR TICKS
				X3=X2+XS*K-XN
		CALL PLOT3D(XROT3D(X3,Y1),YROT3D(X3,Y1),ZROT3D(X3,Y1),3)
		CALL PLOT3D(XROT3D(X3,Y2),YROT3D(X3,Y2),ZROT3D(X3,Y2),2)
120			CONTINUE
110		CONTINUE
100	CONTINUE
	IF (MOD(IABS(N1),1000)/100.NE.0) GOTO 1000 ! NO LABELING
	XS=0.0					! EXPONENT
	IF (E1.LT.0.) GOTO 140			! NO AUTO SCALING
	X1=0.
	Y1=0.
	I=ND-NG-2
	IF (B0.LT.0..OR.C0.LT.0.) I=I-1
	IF (B0.NE.0.) X1=ALOG10(ABS(B0))
	IF (X1.LT.0..AND.X1.NE.AINT(X1)) X1=X1-1.
	X1=AINT(X1)
	IF (C0.NE.0.) Y1=ALOG10(ABS(C0))
	IF (Y1.LT.0..AND.Y1.NE.AINT(Y1)) Y1=Y1-1.
	Y1=AINT(Y1)
	X2=MIN(X1,Y1)
	X3=MAX(X1,Y1)
	IF (X2.LT.0.0.AND.NG.LE.-X2) XS=-NG+1-X2
	IF (I.LT.X3+XS) XS=I-X3-XS
140	Y1=DNY
	Y2=(C0-B0)/(NJT-1)
	E1=XS					! EXPONENT VALUE
	DO 150 I=1,NJT				! LABEL MAJOR TICKS
		X1=(I-1)*XJ+DNX
		C1=(Y2*(I-1)+B0)*10.**E1
		CALL NUM3D(XROT3D(X1,Y1),YROT3D(X1,Y1),ZROT3D(X1,Y1),
     $			PAA,PBA,PGA,CS,C1,FA,HOR)
150	CONTINUE
	IF (E1.NE.0.0) DTX=DTX-CS*3.		! ADD EXPONENT SPACE
	X1=DTX
	Y1=DTY
	IF (NC.NE.0) CALL SYM3D(XROT3D(X1,Y1),YROT3D(X1,Y1),ZROT3D(X1,Y1),
     $		PAA,PBA,PGA,CS,T,NC)
	IF (E1.EQ.0.0) GOTO 1000		! NO EXPONENT
	X1=X1+NC*CS
	CALL SYM3D(XROT3D(X1,Y1),YROT3D(X1,Y1),ZROT3D(X1,Y1),
     $		PAA,PBA,PGA,CS,'(X10)',5)
	X1=X1+4.5*CS
	Y1=Y1+CS/2.
	CS=CS/2.
	CALL NUM3D(XROT3D(X1,Y1),YROT3D(X1,Y1),ZROT3D(X1,Y1),
     $		PAA,PBA,PGA,CS,E1,-1)
1000	RETURN
	END
C
	REAL FUNCTION XVMUL3D(I,X,Y,Z,V,R)
C
C	CREATED: DGL 1-AUG-1984
C
C	RETURNS ONE ELEMENT OF A 3 ELEMENT VECTOR TRANSFORMATION
C
	DIMENSION V(3),R(3)
C
	V(1)=X
	V(2)=Y
	V(3)=Z
	V(4)=0.0
	CALL MTV4(V,R,V)
	XVMUL3D=V(1)
	IF (I.EQ.2) XVMUL3D=V(2)
	IF (I.EQ.3) XVMUL3D=V(3)
	RETURN
	END
